Skip to content

Conversation

@ne0rrmatrix
Copy link
Member

Description of Change

This fixes a bug in Windows where running an app in packaged mode results in media element not finding package resources and failing to playback Media Source from resource directory.

Linked Issues

PR Checklist

  • Has a linked Issue, and the Issue has been approved(bug) or Championed (feature/proposal)
  • Has tests (if omitted, state reason in description)
  • Has samples (if omitted, state reason in description)
  • Rebased on top of main at time of PR
  • Changes adhere to coding standard
  • Documentation created or updated: https://github.com/MicrosoftDocs/CommunityToolkit/pulls

Additional information

To test this change run sample app in packaged and unpackaged mode and load local resource from drop down menu in sample app. It fixes an issue where running app as packaged results in failed media playback when choosing local resource from menu.

I added two Microsoft internal classes and I used null forgiveness operator. I know that is not allowed and would love it if someone could tell me if I should just rewrite the internals or just do the minimum to have it compile. Currently I only made the adjustments to let the app compile. I am happy to fix the use of null operator but I wanted feedback before modifying MS internals.

Copilot AI review requested due to automatic review settings April 1, 2025 14:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug on Windows where media playback fails in packaged mode by ensuring that the MediaElement correctly retrieves package resources.

  • Added a null and whitespace check on ResourceMediaSource.Path before constructing the file path.
  • Introduced two new helper classes (FileSystemUtils and AppInfoUtils) to retrieve and normalize the app package file path on Windows.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
MediaManager.windows.cs Adds a Path check and uses PlatformGetFullAppPackageFilePath to correctly obtain a media file’s URI.
FileSystemUtils.windows.cs Introduces file path normalization and retrieval methods to support packaged app scenarios.
AppInfoUtils.windows.cs Implements app info utilities, including packaged app detection and version retrieval.

@ne0rrmatrix ne0rrmatrix removed the request for review from TheCodeTraveler September 6, 2025 15:45
pictos
pictos previously approved these changes Sep 6, 2025
Copy link
Collaborator

@TheCodeTraveler TheCodeTraveler left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks James & Pedro!!

@TheCodeTraveler TheCodeTraveler merged commit 580df1b into CommunityToolkit:main Sep 6, 2025
17 of 18 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Sep 8, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] 6.0.1 MedialElement doesn't display / load embedded source

4 participants